<template>
    <div class="zs-table-page-container">
        <div class="zs-card-sm zs-space-bottom zs-layout-flex-row zs-layout-justify-between">
            <span>
                <el-input class="zs-select-md zs-space-right-sm" v-model="userName" placeholder="姓名" clearable />
                <el-input class="zs-select-md zs-space-right-sm" v-model="phone" placeholder="电话" clearable />
                <el-button class="zs-btn-plain" @click="getData()">
                    查询
                </el-button>
            </span>
        </div>
        <div class="zs-card zs-table-page-content">
            <el-table :data="tableData" class="zs-table-page-main" :stripe="stripe" v-loading="loading" >
                <el-table-column label="序号" width="60" :align="'center'">
                    <template #default="scope">
                        {{ scope.$index + 1 + curPageSize * (currentPage - 1) }}
                    </template>
                </el-table-column>
                <el-table-column prop="distributeUser" label="姓名" width="120" :align="'center'"></el-table-column>
                <el-table-column label="手机号码" :align="'center'">
                    <template #default="scope">
                        {{ scope.row.distributeUserPhone.replace(scope.row.distributeUserPhone.substring(3,7), "****") }}
                    </template>
                </el-table-column>
                <el-table-column label="分佣订单" :align="'right'">
                    <template #default="scope">
                        {{ toThousands(scope.row.orderNum) }}
                    </template>
                </el-table-column>
                <el-table-column label="实发金额" :align="'right'">
                    <template #default="scope">
                        {{ toThousands(scope.row.distributePrice) }}
                    </template>
                </el-table-column>
                <el-table-column label="到账金额" :align="'right'">
                    <template #default="scope">
                        {{ toThousands(scope.row.realDividePrice) }}
                    </template>
                </el-table-column>
                <el-table-column label="到账比例" :align="'right'">
                    <template #default="scope">
                        {{ scope.row.realDividePriceRatio == '-' ? '-' : `${scope.row.realDividePriceRatio}%` }}
                    </template>
                </el-table-column>
                <el-table-column prop="" label="查看" width="150" :align="'right'">
                    <template #default="scope">
                        <el-button class="zs-link" link size="small" @click="goDetail(scope.row)" disabled>分佣</el-button>
                    </template>
                </el-table-column>
            </el-table>
            <!-- <div class="zs-text-gray-dark zs-text-sm zs-space-top">*销售额：万元；客流量：万人次；车流量：车次</div> -->
            <div class="zs-space-top-sm zs-table-page-pagination">
                <el-pagination v-model:currentPage="currentPage" v-model:page-size="curPageSize" :page-sizes="curPageSizes"
                    :small="true" :background="true" layout="total, sizes, prev, pager, next, jumper" :total="total"
                    @size-change="handleSizeChange" @current-change="handleCurrentChange" />
            </div>
        </div>
    </div>
</template>
<script setup>
import detailApi from '@/api/EnterpriseServices/detailPages'
import { toThousands } from '@/utils/number-util'
import { ref } from 'vue'
import { useStore } from 'vuex'
// import { useRoute, useRouter } from 'vue-router'
// const router = useRouter()
// const route = useRoute().query
let store = useStore()
const stripe = ref(true)

let loading = ref(false)
let userName = ref('')
let phone = ref('')
const tableData = ref([])

// 分页
const curPageSizes = ref(store.state.uiPageSizes)
let curPageSize = ref(store.state.uiPageSizeDefault)
let currentPage = ref(1)
const total = ref(0)
const handleSizeChange = (val) => {
    curPageSize.value = val
    getList()
}
const handleCurrentChange = (val) => {
    currentPage.value = val
    getList()
}

const getList = () => {
    loading.value = true
    detailApi.countDividePersonPriceApi({ phone: phone.value, userName: userName.value, pageNum: currentPage.value, pageSize: curPageSize.value }).then((res) => {
        if (res.data.code == 200) {
            tableData.value = res.data.data.list
            total.value = res.data.data.total
            loading.value = false
        }
    })
}
getList()


const getData = () => {
    currentPage.value = 1
    getList()
}

const goDetail = (row) => {
    console.log(row)
    // router.push({
    //     path: '/page/routeController/index',
    //     query: {
    //         rid: 'EnterpriseServices/detailPages/partnerAssay/partnerAssayMonth',
    //         rTitle: '当月分佣',
    //         companyPlatformId: companyPlatformId.value,
    //         theDate: row.theDate,
    //     },
    // })
}

</script>


<style scoped lang="scss"></style>
